package edu.ptu.communityplatform.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import edu.ptu.communityplatform.domain.entity.Car;
import edu.ptu.communityplatform.domain.vos.CarPageVo;
import edu.ptu.communityplatform.mapper.CarMapper;
import edu.ptu.communityplatform.service.ICarService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @BelongsProject: communityPlatform
 * @BelongsPackage: edu.ptu.communityplatform.service.impl
 * @Author: HYJ
 * @CreateTime: 2025-04-06  22:01
 * @Description: TODO
 * @Version: 1.0
 */
@Service("carService")
public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarService {
    @Resource
    private CarMapper carMapper;

    /**
     * 根据用户id查询车辆id
     *
     * @return carId
     */
    @Override
    public Long getCarIdByPersonId(Long personId) {
        return carMapper.getCarIdByPersonId(personId);
    }


    @Override
    public IPage<CarPageVo> getCarPage(Integer pageNum, Integer pageSize, Long plotId, String carNumber) {
        Page<Car> page = new Page<>(pageNum, pageSize);
        return carMapper.getPage(page, plotId, carNumber);
    }
}
